import pytest,time,logging
from selenium import webdriver
from Page.Page1 import Page1
from Page.Page2 import Page2
from datetime import datetime


@pytest.fixture(scope='function')
def driver():
    driver=webdriver.Edge()
    driver.maximize_window()
    yield driver
    time.sleep(5)
    driver.quit()

def test_baidu_01(driver):
    try:
        logging.info('用例1')
        po=Page1(driver)
        po.luoji_baidu_01_login()
    except Exception as e:
        datime=datetime.now().strftime('%Y%m%d-%H%F%S')
        driver.save_screenshot(f'{datime}.png')
        print(e)

def test_baidu_02(driver):
    try:
        logging.info('用例2')
        po=Page2(driver)
        po.luoji_baidu_02()
    except Exception as e:
        datime=datetime.now().strftime('%Y%m%d-%H%F%S')
        driver.save_screenshot(f'{datime}.png')
        print(e)